import { getDetailApi } from "../../utils/api";
export default {
  state() {
    return {
      detaillist: [],
      newlist: [],
      num: 5,
    };
  },
  mutations: {
    detaildata(state, payload) {
      state.detaillist = payload;
      state.newlist = state.detaillist.slice(0, state.num);
    },
    newlist(state) {
      state.num += 1;
      state.newlist = state.newlist.concat(
        state.detaillist.slice(state.newlist.length, state.num)
      );
      if (state.num >= 21) {
        state.num = 21;
      }
    },
  },
  actions: {
    async detaildata({ commit }) {
      const res = await getDetailApi();
      commit("detaildata", res.list[0].car);
    },
  },

  modules: {},
};
